<!--
 * @Author: DingNanLin 1981261270@qq.com
 * @Date: 2024-08-23 10:20:53
 * @LastEditors: DingNanLin 1981261270@qq.com
 * @LastEditTime: 2024-12-16 16:58:53
 * @FilePath: \platfrom-ui\packages\components\base-table\src\tableColumn.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
    <el-table-column
        :type="columnData.columnType"
        :prop="columnData.columnProp"
        :index="columnData.columnIndex"
        :label="columnData.columnLabel"
        :column-key="columnData.columnKey"
        :width="columnData.columnWidth"
        :min-width="columnData.columnMinWidth"
        :fixed="columnData.columnFixed"
        :render-header="columnData.columnRenderHeader"
        :sortable="columnData.columnSortable"
        :sort-method="columnData.columnSortMethod"
        :sort-by="columnData.columnSortBy"
        :sort-orders="columnData.columnSortOrders"
        :resizable="columnData.columnResizable"
        :formatter="columnData.columnFormatter"
        :show-overflow-tooltip="columnData.columnShowOverflowTooltip"
        :align="columnData.columnAlign"
        :header-align="columnData.columnHeaderAlign"
        :class-name="columnData.columnClassName"
        :label-class-name="columnData.columnLabelClassName"
        :selectable="columnData.columnSelectable"
        :reserve-selection="columnData.columnReserveSelection"
        :filters="columnData.columnFilters"
        :filter-placement="columnData.columnFilterPlacement"
        :filter-class-name="columnData.columnFilterClassName"
        :filter-multiple="columnData.columnFilterMultiple"
        :filter-method="columnData.columnFilterMethod"
        :filtered-value="columnData.columnFilteredValue"
    >
        <template #default="scope" v-if="columnData.columnSlot">
            <slot :name="columnData.columnSlot" :scope="handledScope(scope)">
            </slot>
        </template>
        <template v-if="columnData.children && columnData.children.length > 0">
            <table-column
                v-for="(item, idx) in columnData.children"
                :key="idx"
                :columnData="item"
            >
                <template #default="scope">
                    <slot
                        :name="columnData.columnSlot"
                        :scope="handledScope(scope)"
                    >
                    </slot>
                </template>
            </table-column>
        </template>
    </el-table-column>
</template>
<script lang="ts" name="tableColumn">
import { defineComponent} from 'vue'
export default defineComponent({
    name: 'tableColumn',
    props: {
        columnData: {
            type: Object,
            required: true,
            default: () => {}
        }
    },
    setup() {
        //点击事件
        const handledScope = (scope) => {
            while (
                scope.scope &&
                Object.prototype.toString.call(scope.scope) ===
                    '[object Object]'
            ) {
                scope = scope.scope
            }
            return scope || {}
        }
        return {
            handledScope
        }
    }
})
</script>
